import request from '@/utils/request'

//属性管理模块接口地址
enum API {
  //获取一级分类接口地址
  C1_URL = '/admin/product/getCategory1',
  //获取二级分类接口地址
  C2_URL = '/admin/product/getCategory2/',
  //获取三级分类接口地址
  C3_URL = '/admin/product/getCategory3/',
  //获取分类下已有的属性与属性值
  ATTR_URL = '/admin/product/attrInfoList/',
  //添加或者修改已有的属性的接口
  ADDORUPDATEATTR_URL = '/admin/product/saveAttrInfo',
  //删除某一个已有的属性
  DELETEATTR_URL = '/admin/product/deleteAttr/',
}

class AttrApi {
  //获取一级分类的接口方法
  public static reqC1() {
    return request.get<any, any>(API.C1_URL)
  }

  //获取二级分类的接口方法
  public static reqC2(c1Id: number) {
    return request.get<any, any>(API.C2_URL + c1Id)
  }

  //获取三级级分类的接口方法
  public static reqC3(c2Id: number) {
    return request.get<any, any>(API.C3_URL + c2Id)
  }

  //获取分类下已有的属性与属性值
  public static reqAttr(
    c1Id: number | string,
    c2Id: number | string,
    c3Id: number | string,
  ) {
    return request.get<any, any>(API.ATTR_URL + c1Id + '/' + c2Id + '/' + c3Id)
  }
}

export default AttrApi
